home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 081 / okfile.arc / OKFILE.C next >
Encoding:
C/C++ Source or Header  |  1987-07-10  |  1.8 KB  |  65 lines

  1. #include <stdio.h>
  2. #include <dir.h>
  3. #include <string.h>
  4.  
  5. main(argc,argv)
  6. int     argc;
  7. char    *argv[64];
  8. {
  9.  
  10.     struct   ffblk  ffblk;
  11.     int      done,i,j,k;
  12.     static    char    pass;
  13.     FILE     *infp,*outfp;
  14.     char     path1[64],path2[64];
  15.     char     aline[120],password[64];
  16.  
  17.  
  18.          if(argc<2) usage();
  19.          infp=fopen(argv[1],"r");
  20.          if (argc==3) outfp=fopen(argv[2],"w");
  21.          else outfp=fopen("\\OPUS\\MISC\\OKFILE.LST","w");
  22.          if (outfp == NULL) usage();
  23.          if (infp == NULL) usage();
  24.          while (fgets(aline,120,infp)){
  25.         if ((strspn("!",aline))!=0){
  26.             sscanf(aline,"%s %s",path1,password);
  27.             pass='Y';
  28.             k=strlen(path1);
  29.         }
  30.         if ((strspn("!",aline)) == 0){
  31.             strcpy(path1,aline);
  32.             k=strlen(path1)-1;
  33.             pass='N';
  34.         }
  35.  
  36.                path1[k]='\0';
  37.                for (i=0;i<k;i++) if (path1[i]=='\\')j=i;
  38.                for (i=0;i<=j;i++) path2[i]=path1[i];
  39.                path2[i]='\0';
  40.            printf("%s",aline);    
  41.               done=findfirst(path1,&ffblk,0);
  42.                while (!done){
  43.              if (pass=='Y') fprintf(outfp,"%s%s %s\n",path2,ffblk.ff_name,password);
  44.                         if (pass=='N') fprintf(outfp,"%s%s\n",path2,ffblk.ff_name);
  45.                      done=findnext(&ffblk);
  46.                }
  47.          }
  48.          fclose(infp);
  49.          fclose(outfp);
  50.         exit(0);
  51. }
  52.  
  53. usage()
  54. {
  55.  printf("\n\n\n\n To Use:\n\n");
  56.  printf("OKFILE INFILE.EXT [OUTFILE.EXT]\n\n");
  57.  printf("Where INFILE.EXT is a list of directories/files that are file-requestable \n");
  58.  printf("on your system. Wildcards are allowed. Each line of should be like:\n");
  59.  printf(" C:\\Opus\\Files\\Ms-Dos\\*.* \n C:\\Opus\\Files\\Opusbbs\\O???_000.arc\n\n");
  60.  printf("OUTFILE.EXT is the filename from OPUS.CTL for OKFILE.LST, and the default \n");
  61.  printf("is '\\Opus\\Misc\\OKFILE.LST'.\n\n");
  62.  exit(1);
  63. }
  64.  
  65.